﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BOSS.Framework.Search.Result
{
    /// <summary>
    /// 结果架构定义类
    /// </summary>
    public class ResultSchema
    {
        private IList<ResultFieldSchema> m_fieldSchemas;

        /// <summary>
        /// 构造函数
        /// </summary>
        public ResultSchema()
            : this(false)
        {
        }

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="includeOtherFields"></param>
        public ResultSchema(bool includeOtherFields)
        {
            this.IncludeOtherFields = includeOtherFields;
            this.m_fieldSchemas = new List<ResultFieldSchema>();
        }

        /// <summary>
        /// 获取 / 设置 是否包含其他字段
        /// </summary>
        public bool IncludeOtherFields { get; set; }

        /// <summary>
        /// 获取 字段架构的数量
        /// </summary>
        public int FieldSchemaCount
        {
            get
            {
                return this.m_fieldSchemas.Count;
            }
        }

        /// <summary>
        /// 获取 字段架构集合
        /// </summary>
        public IEnumerable<ResultFieldSchema> FieldSchemas
        {
            get
            {
                return this.m_fieldSchemas;
            }
        }

        /// <summary>
        /// 创建结果字段架构
        /// </summary>
        /// <param name="fieldName"></param>
        /// <returns></returns>
        public ResultFieldSchema CreateFieldSchema(string fieldName)
        {
            return new ResultFieldSchema(fieldName);
        }

        /// <summary>
        /// 添加结果字段架构
        /// </summary>
        /// <param name="fieldSchame"></param>
        public void AddFieldSchame(ResultFieldSchema fieldSchame)
        {
            this.m_fieldSchemas.Add(fieldSchame);
        }
    }
}
